package com.zq.sysuser.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zq.sysuser.dao.entity.SysOperLog;
import com.zq.sysuser.mapper.SysOperLogMapper;
import com.zq.sysuser.service.ISysOperLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 操作日志记录 服务实现类
 * </p>
 *
 * @author 张乔
 * @since 2025-05-28
 */
@Service
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService {

    //    分页条件查询日志记录
    @Override
    public PageInfo<SysOperLog> getPageList(Integer page, Integer limit, String userName) {
        PageHelper.startPage(page, limit);
        List<SysOperLog> operLogList = this.list(new LambdaQueryWrapper<SysOperLog>().
                like(StringUtils.hasText(userName), SysOperLog::getOperName, userName)
                .orderByDesc(SysOperLog::getCreateTime));
PageInfo<SysOperLog> pageInfo = new PageInfo<>(operLogList);
        return pageInfo;
    }
}
